using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Newtonsoft.Json.Linq;
using ns20;

namespace Newtonsoft.Json.Schema
{
	public static class Extensions
	{
		[CompilerGenerated]
		private sealed class Class119
		{
			public bool bool_0;

			public void method_0(object sender, ValidationEventArgs e)
			{
				bool_0 = false;
			}
		}

		[CompilerGenerated]
		private sealed class Class120
		{
			public IList<string> ilist_0;

			public void method_0(object sender, ValidationEventArgs e)
			{
				ilist_0.Add(e.Message);
			}
		}

		public static bool IsValid(this JToken source, JsonSchema schema)
		{
			bool bool_0 = true;
			source.Validate(schema, delegate
			{
				bool_0 = false;
			});
			return bool_0;
		}

		public static bool IsValid(this JToken source, JsonSchema schema, out IList<string> errorMessages)
		{
			IList<string> ilist_0 = new List<string>();
			source.Validate(schema, delegate(object sender, ValidationEventArgs e)
			{
				ilist_0.Add(e.Message);
			});
			errorMessages = ilist_0;
			return errorMessages.Count == 0;
		}

		public static void Validate(this JToken source, JsonSchema schema)
		{
			source.Validate(schema, null);
		}

		public static void Validate(this JToken source, JsonSchema schema, ValidationEventHandler validationEventHandler)
		{
			Class204.smethod_2(source, "source");
			Class204.smethod_2(schema, "schema");
			using JsonValidatingReader jsonValidatingReader = new JsonValidatingReader(source.CreateReader());
			jsonValidatingReader.Schema = schema;
			if (validationEventHandler != null)
			{
				jsonValidatingReader.ValidationEventHandler += validationEventHandler;
			}
			while (jsonValidatingReader.Read())
			{
			}
		}
	}
}
